package src.com.hpu.parser;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;

import com.hpu.bean.Book;
import com.hpu.bean.Lecture;
import com.hpu.bean.News;

public class LectureParser{

	public List<Lecture> parse(String parseString) {
		List<Lecture> lectures=new ArrayList<>();
		try {
			JSONObject object=new JSONObject(parseString);
			String prefix=object.getString("prefix");
			JSONArray array=object.getJSONArray("data");
			
			for(int i=0;i<array.length();i++){
				JSONObject object2=array.getJSONObject(i);
				lectures.add(new Lecture(prefix+object2.getString("id"), object2.getString("name"),object2.getString("time")));
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return lectures;
	}
}
